(function($){
    $(document).ready(function () {
        /*模板引擎设置*/
        _.templateSettings = {
            interpolate: /\{\{(.+?)\}\}/g
        };

        var BuyerModel=Backbone.NestedModel.extend({});
        var buyerModel=new BuyerModel();
        buyerModel.set({
            address:[
                {city:"Brooklyn",state:"NY"},
                {city:"Oak Park",state:"IL"}
            ]
        });

        buyerModel.set({
            'address[2].city':'Danver',
            'address[2].state':'MI'
        });

        buyerModel.add('address',{
            'city':'beijing',
            'state':"bj"
        });

        //buyerModel.remove('address[3]');

        buyerModel.bind('change:address[0].city',function(model,value){
            console.log(value," change");
        });

        console.log(buyerModel.get("address[2].state"));
        console.log(buyerModel.get("address[3].state"));
        console.log("====================");

        buyerModel.set("address[0].city","Chicago");
    });
})(jQuery);